#pragma once

#include <GL/glew.h>
#include <iostream>

namespace cagd
{
    class TCoordinate
    {
    public:
        GLfloat s, t, r, q;

        TCoordinate(): s(0.0f), t(0.0f), r(0.0), q(1.0) {}

        TCoordinate(GLfloat s, GLfloat t, GLfloat r = 0.0, GLfloat q = 1.0): s(s), t(t), r(r), q(q)
        {}

        GLfloat operator[](GLint i) const
        {
            switch (i)
            {
            case 0:
                return s;
            case 1:
                return t;
            case 2:
                return r;
            default:
                return q;
            }
        }


        // homework
        GLfloat& operator[](GLint i)
        {
            switch (i)
            {
            case 0:
                return s;
            case 1:
                return t;
            case 2:
                return r;
            default:
                return q;
            }
        }
    };

    inline std::ostream& operator <<(std::ostream& lhs, const TCoordinate& rhs)
    {
        return lhs << rhs.s << " " << rhs.t << " " << rhs.r << " " << rhs.q;
    }

    // homework
    inline std::istream& operator >>(std::istream& lhs, TCoordinate& rhs)
    {
        return lhs >> rhs.s >> rhs.t >> rhs.r >> rhs.q;
    }

}
